local vineSkill = fk.CreateSkill {
  name = "#lvshi__vine_skill",
  tags = { Skill.Compulsory },
  attached_equip = "lvshi__vine",
}

vineSkill:addEffect(fk.PreCardEffect, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    local names = {"drowning", "savage_assault", "archery_attack"}
    return data.to == player and player:hasSkill(vineSkill.name) and
    (data.card.name == "slash" or data.card.name == "lvshi__slash"
      or table.contains(names, data.card.trueName))
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/maneuvering/audio/card/vine")
    room:setEmotion(player, "./packages/maneuvering/image/anim/vine")
    data.nullified = true
  end,
})

vineSkill:addEffect(fk.Damaged, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(vineSkill.name) and data.damageType == fk.FireDamage
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/maneuvering/audio/card/vineburn")
    room:setEmotion(player, "./packages/maneuvering/image/anim/vineburn")
    local cards = table.filter(player:getEquipments(Card.SubtypeArmor), function(id)
      return Fk:getCardById(id).name == "lvshi__vine"
    end)
    player.room:throwCard(cards, vineSkill.name, player, player)
    if not player.dead then
      room:loseHp(player, 1, vineSkill.name)
    end
  end,
})

return vineSkill